#include "th_sensor_inf.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static uint8_t DTH11_close(th_sensor_handle *handle)
{
    printf("One Wire Uninit\r\n");
    printf("DTH11_close\r\n");
    return TH_SENSOR_OK;
}

static uint8_t DTH11_open(th_sensor_handle *handle)
{
    printf("DTH11_open\r\n");
    printf("One Wire Init\r\n");
    return TH_SENSOR_OK;
}

static uint8_t DTH11_read(th_sensor_handle *handle)
{
    printf("DTH11_read\r\n");
    printf("One Wire Read\r\n");
    handle->temp = 26.0f;
    handle->humi = 68.0f;
    return TH_SENSOR_OK;
}

th_sensor_handle *DTH11_new()
{
    th_sensor_handle *dht11 = (th_sensor_handle *)malloc(sizeof(th_sensor_handle));
    if (dht11 == NULL)
        return NULL;
    memset(dht11, 0x00, sizeof(th_sensor_handle));
    dht11->close = DTH11_close;
    dht11->open = DTH11_open;
    dht11->read = DTH11_read;
    dht11->temp = 0.0f;
    dht11->humi = 0.0f;
    return dht11;
}